#include "Data.h"

vector<string> myCData::s_aType;
vector<string> myCData::s_aBaseType;
QMap<string,QMetaObject> myCData::s_mapTypeToClass;

void myCData::RegisterClass(string strType,QMetaObject metaObject, bool bBaseType)
{
    if(""==strType) return;
    QMap<string,QMetaObject>::iterator iter;
    for(iter = s_mapTypeToClass.begin();iter != s_mapTypeToClass.end();iter++)
    {

       if(strType ==iter.key() ||  metaObject.className()== iter.value().className())return;
    }
    s_mapTypeToClass.insert(strType,metaObject);
    s_aType.push_back(strType);
    if(bBaseType)
    {
        s_aBaseType.push_back(strType);
    }
}

string myCData::GetType(QMetaObject metaObject)
{
    QMap<string,QMetaObject>::iterator iter;
    for(iter = s_mapTypeToClass.begin();iter != s_mapTypeToClass.end();iter++)
    {

       if(metaObject.className()== iter.value().className())
       {
           iter.key();
       }

    }
    return "";
}


myCData::myCData(QObject *parent) : QObject(parent)
{

}

myCData::~myCData()
{

}

string myCData::GetFullName()
{
    string strFullName =  "<" + m_strParentUnit + "><" + m_strName + ">";
    return strFullName;
}

string myCData::GetFieldAndName()
{
    string strFieldAndName = m_strField + ":" + m_strName;
    return strFieldAndName;
}

void myCData::OnUpdateParentUnit(string strParentUnit)
{
    m_strParentUnit = strParentUnit;
}
